﻿using System.Windows;
using System.Windows.Input;
using MaxAlarm.Core.Items;
using MaxAlarm.ViewModels;

namespace MaxAlarm.Windows
{
    /// <summary>
    /// Interaction logic for MessageBox.xaml
    /// </summary>
    public partial class MaxMessageBox : Window
    {
        public static readonly DependencyProperty DialogResultProperty =
            DependencyProperty.Register("DialogResult", typeof(DialogResult), typeof(MaxMessageBox));

        public new DialogResult DialogResult
        {
            get { return (DialogResult)GetValue(DialogResultProperty); }
            set { SetValue(DialogResultProperty, value); }
        }

        public static readonly DependencyProperty ViewModelProperty =
            DependencyProperty.Register("ViewModel", typeof (MessageBoxViewModel), typeof (MaxMessageBox), new PropertyMetadata(null));

        public MessageBoxViewModel ViewModel
        {
            get { return (MessageBoxViewModel) GetValue(ViewModelProperty); }
            set { SetValue(ViewModelProperty, value); }
        }

        #region Ctors

        public MaxMessageBox()
        {
            InitializeComponent();
        }

        public MaxMessageBox(string title, string message, MessageLevel level, MessageBoxButton buttons,  Window owner)
            : this()
        {
            ViewModel = new MessageBoxViewModel();
            ViewModel.MessageTitle = title;
            ViewModel.MessageText = message;
            ViewModel.MessageLevel = level;
            Owner = owner;
            ViewModel.Buttons = buttons;
        }

        #endregion

        private void DragWindow(object sender, MouseButtonEventArgs e)
        {
            DragMove();
        }

        private void CloseWindow(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}
